﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Data;
using Volo.Abp.Domain.Entities;
using Volo.Abp.MultiTenancy;

namespace Himp.TaskScheduling
{
    /// <summary>
    /// 业务流配置
    /// </summary>
    public class BizflowConfig : Entity<Guid>, IMultiTenant, ISoftDelete, IHasExtraProperties
    {
        /// <summary>
        /// 业务流程名称
        /// </summary>
        public string BizflowName { get; set; }

        /// <summary>
        /// 业务流程类别代码
        /// </summary>
        public string BizflowCode { get; set; }

        /// <summary>
        /// 工作流模型Key
        /// 部署Key:版本：
        /// </summary>
        public string WorkflowModelKey { get; set; }

        /// <summary>
        /// 工作流模型名称
        /// </summary>
        public string WorkflowModelName { get; set; }

        /// <summary>
        /// 工作流授权提供器
        /// </summary>
        public EnumWorkflowTypeProvider WorkflowTypeProvider { get; set; }

        /// <summary>
        /// 提供值
        /// </summary>
        public string? ProviderKey { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public List<BizflowNode> BizflowNodes { get; set; }

        /// <summary>
        /// 有效标识
        /// </summary>
        public bool ValiFlag { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public Guid? TenantId { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public bool IsDeleted { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public ExtraPropertyDictionary ExtraProperties { get; set; }


        public BizflowConfig(string processTypeCodg, string processTypeName)
        {
            WorkflowModelKey = processTypeCodg;
            WorkflowModelName = processTypeName;
            ExtraProperties = new ExtraPropertyDictionary();
        }

        public BizflowConfig()
        {
            ExtraProperties = new ExtraPropertyDictionary();
        }
    }

    ///// <summary>
    ///// 
    ///// </summary>
    //public static class WorkflowTypeExtensions
    //{
    //    private const string StColumn = "StColumn";

    //    public static void SetStColumns(this BizflowConfig item, List<WorkflowTypeStColumn> pars)
    //    { 
    //        //var jsonValue = JsonConvert.SerializeObject(pars);
    //        item.SetProperty(StColumn, pars);
    //    }

    //    public static List<WorkflowTypeStColumn> GetStColumns(this BizflowConfig item)
    //    {
    //        return item.Property<List<WorkflowTypeStColumn>>(StColumn);
    //    }
    //}

    /// <summary>
    /// 
    /// </summary>
    public class WorkflowTypeStColumn
    {
        /// <summary>
        /// 标题
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// 类型
        /// </summary>
        public string Type { get; set; }

        /// <summary>
        /// 编号
        /// </summary>
        public string Index { get; set; }

        /// <summary>
        /// 值类别
        /// </summary>
        public string ValueKind { get; set; }

        /// <summary>
        /// 显示列
        /// </summary>
        public bool ShowColumn { get; set; }

        /// <summary>
        /// 显示内容描述
        /// </summary>
        public bool ShowContdesc { get; set; }
    }
}
